import request from '@/utils/request'

export const getExamListService = (params) => {
  return request.get('/exam/list', { params })
}

export const examAddService = (params = {}) => {
  return request({
    url: '/exam/add',
    method: 'post',
    data: params
  })
}

export const addExamQuestionService = (params = {}) => {
  return request({
    url: '/exam/question/add',
    method: 'post',
    data: params
  })
}

export const getExamDetailService = (examId) => {
  return request({
    url: '/exam/detail',
    method: 'get',
    params: { examId }
  })
}

export const editExamService = (params = {}) => {
  return request({
    url: '/exam/edit',
    method: 'put',
    data: params
  })
}

export const delExamQuestionService = (examId, questionId) => {
  return request({
    url: '/exam/question/delete',
    method: 'delete',
    params: { examId, questionId }
  })
}

export const delExamService = (examId) => {
  return request({
    url: '/exam/delete',
    method: 'delete',
    params: { examId }
  })
}

export const publishExamService = (examId) => {
  return request({
    url: '/exam/publish',
    method: 'put',
    params: { examId }
  })
}

export const cancelPublishExamService = (examId) => {
  return request({
    url: '/exam/cancelPublish',
    method: 'put',
    params: { examId }
  })
}
